<?
/**
*  工单管理
*  2013/7/14 by zh
*/
include("../webkit/include/simple_db.php");

require("ajax_base.php");

$db = new SimpleDB();
$tel = $_GET['telephone'];

if(empty($tel)) {
	echo "telephone missing!";
	exit;
}

$sql = "select order_no from jx_order where client_id in (select id from jx_client where mobilephone='$tel' or telephone1='$tel') 
and call_time > '". date("Y-m-d H:i:s", strtotime("-30 minutes")) ."' order by id desc";
$order_no = $db->getOneValue($sql);  // 确认已有首次外勤联系 ( 受理30分钟之内有效 )

if(empty($order_no)) {
	echo "no record!";
	exit;
}

$sql = "update jx_order set user_called=1 where order_no='$order_no'"; 
$db->query($sql);
echo "ok";

?>